import 'package:flutter/material.dart';

class Mine extends StatefulWidget {
  @override
  _MineState createState() => _MineState();
}

class _MineState extends State<Mine> {
  List menuTopList = [
    {"icon": Icons.account_box, "name": "个人资料", "path": ""},
    {"icon": Icons.beenhere, "name": "我的收藏", "path": ""},
    {"icon": Icons.assignment, "name": "浏览记录", "path": ""},
    {"icon": Icons.store, "name": "优惠卷", "path": ""},
    {"icon": Icons.markunread, "name": "发票管理", "path": ""}
  ];

  List menuBottomList = [
    {"icon": Icons.chat, "name": "帮助反馈", "path": ""},
    {"icon": Icons.scanner, "name": "扫码", "path": ""},
    {"icon": Icons.access_alarm, "name": "打电话", "path": ""},
    {"icon": Icons.brightness_high, "name": "设置", "path": ""}
  ];


  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: Container(
        color: Color.fromRGBO(248, 248, 248, 1),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Container(
              alignment: Alignment.centerLeft,
              height: 180,
              color: Color.fromRGBO(244, 116, 53, 1),
              padding: EdgeInsets.only(left: 20, right: 20, top: 44),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Container(
                    alignment: Alignment.centerRight,
                    margin: EdgeInsets.only(bottom: 20),
                    child: Icon(
                      Icons.notifications,
                      color: Colors.white,
                    ),
                  ),
                  buildUser(),
                ],
              ),
            ),
            Container(
              margin: EdgeInsets.only(top: 10),
              color: Colors.white,
              child: Column(
                children: menuTopList.map((e) => _renderMenu(e)).toList(),
              ),
            ),
            Container(
              margin: EdgeInsets.only(top: 10),
              color: Colors.white,
              child: Column(
                children: menuBottomList.map((e) => _renderMenu(e)).toList(),
              ),
            )
          ],
        ),
      ),
    );
  }

  Widget buildUser() {
    return InkWell(
      highlightColor: Colors.transparent,
      splashColor: Colors.transparent,
      child: Container(
        height: 55,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            ClipRRect(
              borderRadius: new BorderRadius.circular(27),
              child: Image.asset("assets/image/image_3.png",
                  width: 55, height: 55, fit: BoxFit.fill),
            ),
            Expanded(
              child: Container(
                margin: EdgeInsets.only(left: 10),
                child: Text(
                  "立即登录",
                  style: TextStyle(color: Colors.white, fontSize: 16),
                ),
              ),
            ),
            Icon(
              Icons.arrow_forward_ios,
              color: Colors.white,
              size: 18,
            )
          ],
        ),
      ),
      onTap: () {
        print("登录");
      },
    );
  }

  Widget _renderMenu(e) {
    return InkWell(
      highlightColor: Colors.transparent,
      splashColor: Colors.transparent,
      child: Stack(
        children: [
          Container(
            height: 55,
            padding: EdgeInsets.symmetric(horizontal: 10),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Container(
                  width: 40,
                  alignment: Alignment.center,
                  child: Icon(
                    e['icon'],
                    color: Color(0xff999999),
                    size: 20,
                  ),
                ),
                Expanded(
                  child: Container(
                    margin: EdgeInsets.only(left: 5),
                    child: Text(
                      e['name'],
                      style: TextStyle(color: Colors.black, fontSize: 16),
                    ),
                  ),
                ),
                Icon(
                  Icons.arrow_forward_ios,
                  color: Color.fromRGBO(0, 0, 0, 0.1),
                  size: 18,
                )
              ],
            ),
          ),
          Positioned(
            bottom: 0,
            left: 45,
            child: Container(
              height: 0.1,
              width: MediaQuery.of(context).size.width - 45,
              color: Color.fromRGBO(0, 0, 0, 0.4),
            ),
          )
        ],
      ),
      onTap: () {
        print(e['name']);
        if (e['name'] == '扫码') {
          
        }
      },
    );
  }
}